/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package testgui;

/**
 *
 * @author Administrator
 */
public class Engine {

    private int[] intArraySizeOfGrid = new int[2];
    private int[][] intArrayPositions;
    
    public Engine(int x, int y)
    {
        intArraySizeOfGrid[0] = x;
        intArraySizeOfGrid[1] = y;
    }
    
    private boolean isLegalToMoveNorthWest(Player player)
    {
        if(player.getXPos() > 16 && player.getYPos() > 27)
        {
            return true;
        }
     
        else
        {
            return false;
        }
        
    }    
    private boolean isLegalToMoveNorth(Player player)
    {
        return true;
    }
     private boolean isLegalToMoveNorthEast(Player player)
    {
        if(player.getXPos() < intArraySizeOfGrid[0] - 32 
                && player.getYPos() > 32)
        {
            return true;
        }
        
        else
        {
            return false;
        }
    }
     private boolean isLegalToMoveWest(Player player)
    {
         if(player.getXPos() > 32 )
          {
            return true;
          }
         
         else
        {
            return false;
        }
   
    }
     private boolean isLegalToMoveEast(Player player)
    {
         if(player.getXPos() < intArraySizeOfGrid[0] - 50)
          {
            return true;
          }
         
         else
        {
            return false;
        }
   
    }
     private boolean isLegalToMoveSouthWest(Player player)
    {
         if(player.getXPos() > 16 && 
                 player.getYPos() < intArraySizeOfGrid[1] - 32)
            {
                return true;
            }
         
         else
        {
            return false;
        }
     }  
     private boolean isLegalToMoveSouth(Player player)
    {
        return true;
    }     
     private boolean isLegalToMoveSouthEast(Player player)
    {
         if(player.getXPos() <  intArraySizeOfGrid[0] - 32
                  && player.getYPos() < intArraySizeOfGrid[1] - 32)
          {
            return true;
          }
         
         else
        {
            return false;
        }
             
    }

    
    public boolean requestPlayerMoveNorthWest(Player player, SimpleGUI sGUI)
    {

        if(isLegalToMoveNorthWest(player))
        {
            sGUI.changeJLabelPosition(player.getJLabel(), player.getXPos() - 16, 
            player.getYPos() - 27);
            return true;
        }
        
        else
        {
            return false;
        }
    }
    
    public boolean requestPlayerMoveNorthEast(Player player, SimpleGUI sGUI)
    {
        if(isLegalToMoveNorthEast(player))
        {
            sGUI.changeJLabelPosition(player.getJLabel(), player.getXPos() + 16, 
            player.getYPos() - 27);
            
            return true;
        }
        
        else
        {
            return false;
        }
    }
    
    public boolean requestPlayerMoveEast(Player player, SimpleGUI sGUI)
    {
        if(isLegalToMoveEast(player))
        {
            sGUI.changeJLabelPosition(player.getJLabel(), player.getXPos() + 32, 
            player.getYPos() + 0);
            return true;
        }
        
        else
        {
            return false;
        }
    }
    
    public boolean requestPlayerMoveWest(Player player, SimpleGUI sGUI)
    {
        if(isLegalToMoveWest(player))
        {
            sGUI.changeJLabelPosition(player.getJLabel(), player.getXPos() - 32, 
            player.getYPos() + 0);
            
            return true;
        }
        
        else
        {
            return false;
        }
    }
    
    public boolean requestPlayerMoveSouthWest(Player player, SimpleGUI sGUI)
    {
        if(isLegalToMoveSouthWest(player))
        {
         sGUI.changeJLabelPosition(player.getJLabel(), player.getXPos() - 16, 
            player.getYPos() + 27);
         
         return true;
        }
        
        else
        {
            return false;
        }
        
    }
    
    public boolean requestPlayerMoveSouthEast(Player player, SimpleGUI sGUI)
    {
        if(isLegalToMoveSouthEast(player))
        {
         sGUI.changeJLabelPosition(player.getJLabel(), player.getXPos() + 16, 
            player.getYPos() + 27);
         return true;
        }
        
        else
        {
            return false;
        }
    }
    
    
    
}
